package com.huike.web.controller.report;


import com.huike.business.domain.TbBusiness;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * 指数控制器
 *
 * @author zhouao
 * @date 2022/05/14
 */
@RestController
@RequestMapping("/index")
public class IndexController {

    /**
     * 报告服务
     */
    @Autowired
    private IReportService reportService;


    /**
     * 得到基本信息
     * 首页--基础数据统计
     *
     * @param beginCreateTime 开始创建时间
     * @param endCreateTime   最终创建时间
     * @return {@link AjaxResult}
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 获取今天待处理项
     *
     * @return AjaxResult
     * @author Administrator
     * @description TODO
     * @date 2022/5/16 13:59
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String time = simpleDateFormat.format(date);
        return AjaxResult.success(reportService.getTodayInfo(time));
    }

    /**
     * 查询当前用户待根进的线索，商机，和待分配的线索和商机
     *
     * @param beginCreateTime: 开始时间
     * @param endCreateTime:   结束时间
     * @return AjaxResult
     * @author Administrator
     * @description TODO
     * @date 2022/5/16 16:46
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页--商机转化龙虎榜接口
     *
     * @param beginCreateTime:
     * @param endCreateTime:
     * @return AjaxResult
     * @author Administrator
     * @description TODO
     * @date 2022/5/17 19:27
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(String beginCreateTime, String endCreateTime) {
        return AjaxResult.success(reportService.businessChangeStatistics(beginCreateTime, endCreateTime));
    }

    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistics(@RequestParam("beginCreateTime") String beginCreateTime,@RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.clueChangeStatisticsForIndex(beginCreateTime,endCreateTime));
    }
}